import {createSlice} from "@reduxjs/toolkit";
import axios from "axios";



const billStore = createSlice({
    name:'bill',
    initialState:{
        billList:[]
    },
    reducers:{
        setBillList(state,action){
            state.billList = action.payload
        }
    }
})
//结构actionCreater函数
const {setBillList} = billStore.actions
// 导出reducer
const reducer = billStore.reducer
// 编写异步
const getBillList = () => {
    return async (dispatch)=>{
        const res = await axios.get('http://localhost:8888/ka')
        dispatch(setBillList(res.data))
    }
}
export {getBillList}
export default reducer

